 <?php 
 //This is only displayed if they have submitted the form 
 
 require_once('php/connection.php'); 
 
 $searching = $_POST['searching'];
 $find = $_POST['find'];
 
 if ($searching =="yes") 
 { 
 //And we remind them what they searched for 
 echo '<br><span class="small-font"> <b>Searched For:</b> ' .$find.'</span><br>'; 
 
 //If they did not enter a search term we give them an error 
 if ($find == "") 
 { 
 echo "<p>You forgot to enter a search term"; 
 } 
 else
 {

 // We preform a bit of filtering 
 $find = strtoupper($find); 
 $find = strip_tags($find); 
 $find = trim ($find); 
 
 //Now we search for our search term, in the field the user specified 
 $data = mysql_query("SELECT * FROM site_groups WHERE upper(`name`) LIKE '%$find%' AND `visibility`!='closed' AND `del`!='1' UNION SELECT * FROM site_groups WHERE upper(`description`) LIKE '%$find%' AND `visibility`!='closed' AND `del`!='1' ");  
 
 $anymatches=mysql_num_rows($data); 
 if ($anymatches == 0) 
 { 
 echo '<span class="small-font">'.'Sorry, but we can not find an entry to match your query</span><br><br>'; 
 }
 else
 {
	echo '<span class="small-font">'.$anymatches.' results found.</span><br><br>'; 
 }
 
 //And we display the results 
 while($result = mysql_fetch_array( $data )) 
 { 
	$id = $result['id'];
	$n = mysql_numrows(mysql_query("SELECT * FROM site_group_members WHERE `gpid`='$id' AND `del`!='1'"));
	
 echo '<div class="search_result">';
 echo '<a href="index.php?cat=group&action=info&gpid='.$result['id'].'"><strong>'.$result['name'].'</strong></a><br>';
 if($result['description']!="")
 echo '<span class="small-font">'.$result['description'].'</span><br>';
 echo '<span class="small-font" style="color:#555">'.$n.' member(s)</span>';
 echo '</div><br>';
 } 
 
 //This counts the number or results - and if there wasn't any it gives them a little message explaining that 
 
 

 }
 } 
 ?> 